package com.ruoyi.web.controller.loan.controller;

import com.github.pagehelper.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.loan.dto.BeliefRecordDto;
import com.ruoyi.loan.entity.BeliefRecord;
import com.ruoyi.loan.service.BeliefRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author lin
 * @Date 2022/4/5 3:02
 */

@Api(tags = "诚信管理")
@Controller
@RequestMapping("/loan/belief")
public class BeliefRecordController {

    @Resource
    private BeliefRecordService beliefRecordService;

    @GetMapping("")
    public String belief(){
        String prefix = "loan/belief";
        return prefix + "/belief";
    }

    /**
     * 添加失信名单
     * @param beliefRecord 记录信息
     * @return
     */
    @ApiOperation(value = "添加失信名单",notes = "添加失信名单")
    @ResponseBody
    @PostMapping("/save")
    public AjaxResult saveBeliefRecord(@RequestBody BeliefRecord beliefRecord){
        beliefRecordService.saveBelief(beliefRecord);
        return AjaxResult.success();
    }

    /**
     * 获取失信列表
     * @param dto 参数信息
     * @return
     */
    @ApiOperation(value = "获取失信名单",notes = "获取失信名单")
    @ResponseBody
    @GetMapping("/getBeliefList")
    public AjaxResult getBeliefList(BeliefRecordDto dto){
        PageInfo pageInfo = beliefRecordService.selectBeliefRecordList(dto);
        return AjaxResult.success(pageInfo);
    }

}
